package com.github.llyb120.calengine.method;

import com.alibaba.fastjson.JSONObject;
import com.github.llyb120.calengine.entity.ScopeData;
import com.github.llyb120.calengine.rule.RuleEngine;

import java.util.List;

public class DrawPieFunc extends AbstractScriptFunc{
    public DrawPieFunc(RuleEngine ruleEngine) {
        super(ruleEngine);
    }

    @Override
    public Object call(Object... args) {
        if(args.length > 0 && args[0] instanceof List){
            List<ScopeData> scopeData = (List) args[0];
            JSONObject map = new JSONObject();
            map.put("draw", "pie");
            map.put("data", scopeData);
            map.put("config", null);
            return map;
        }
        return super.call(args);
    }
}
